<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:p="http://primefaces.org/ui" lang="pt-br">
<body>

	<ui:composition template="template/template.xhtml">

		<ui:define name="titulo">
		Carrinho de compras
	</ui:define>

		<ui:define name="conteudo">

			<p:panel header="Carrinho de compras">
				<p:dataTable id="cartTable" var="item"
					value="#{carrinhoController.carrinho}">
					<p:column id="modelHeader">
						<f:facet name="header">  
				                    Descricao  
				            </f:facet>
						<h:outputText value="#{item.produto.prodNome}" />
					</p:column>

					<p:column>
						<f:facet name="header">  
				                    Quantidade  
				            </f:facet>
						<p:inputText value="#{item.qtd}" size="2" maxlength="2"/>
					</p:column>

					<p:column width="50">
						<f:facet name="header">  
				                    Preco Unitario  
				            </f:facet>
						<h:outputText
							value="#{item.produto.preco-(item.produto.preco*item.produto.desconto)/100}">
							<f:convertNumber type="currency" />
						</h:outputText>
					</p:column>

					<p:column width="50">
						<f:facet name="header">  
				                    Total Parcial  
				            </f:facet>
						<h:outputText value="#{item.subTotal}">
							<f:convertNumber type="currency" />
						</h:outputText>
					</p:column>

					<p:column width="10">
						<f:facet name="header">
							<h:outputText value="" />
						</f:facet>
						<p:commandButton id="excluir"
							action="#{carrinhoController.removerProduto}" ajax="false"
							icon="ui-icon-close" title="Excluir do Carrinho">
							<f:param name="id" value="#{item.produto.id}" />
						</p:commandButton>
					</p:column>

					<f:facet name="footer">
						<h:outputText value="Total do pedido: " />
						<h:outputText value="#{carrinhoController.car.total}">
							<f:convertNumber type="currency" />
						</h:outputText>
					</f:facet>

				</p:dataTable>

				<h:panelGrid columns="2" cellpadding="5">

					<f:facet name="footer" style="float: right;">
						<p:commandButton id="comprarMais" value="Comprar Mais"
							action="home.jsf" ajax="false" />
						<p:commandButton id="atualizarValor"
							value="Atualizar os valores do Carrinho"
							action="#{carrinhoController.atualizarQtd}" ajax="false" />
						<p:commandButton id="userLogar" value="Finalizar Compra"
							action="#{usuarioController.logar}" ajax="false" />
					</f:facet>
				</h:panelGrid>
			</p:panel>
		</ui:define>

	</ui:composition>

</body>
</html>
